package com.arellomobile.android.push.utils;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;

public class GeneralUtils
{
  private static final String SHARED_KEY = "deviceid";
  private static final String SHARED_PREF_NAME = "com.arellomobile.android.push.deviceid";
  private static List<String> sWrongAndroidDevices = new ArrayList();

  static
  {
    sWrongAndroidDevices.add("9774d56d682e549c");
  }

  public static void checkNotNull(Object paramObject, String paramString)
  {
    if (paramObject == null)
      throw new IllegalArgumentException(String.format("Please set the %1$s constant and recompile the app.", new Object[] { paramString }));
  }

  public static void checkNotNullOrEmpty(String paramString1, String paramString2)
  {
    checkNotNull(paramString1, paramString2);
    if (paramString1.length() == 0)
      throw new IllegalArgumentException(String.format("Please set the %1$s constant and recompile the app.", new Object[] { paramString2 }));
  }

  public static boolean checkStickyBroadcastPermissions(Context paramContext)
  {
    return paramContext.getPackageManager().checkPermission("android.permission.BROADCAST_STICKY", paramContext.getPackageName()) == 0;
  }

  public static String getDeviceUUID(Context paramContext)
  {
    String str1 = Settings.Secure.getString(paramContext.getContentResolver(), "android_id");
    Object localObject;
    if ((str1 != null) && (!sWrongAndroidDevices.contains(str1)))
      localObject = str1;
    while (true)
    {
      return localObject;
      try
      {
        String str3 = ((TelephonyManager)paramContext.getSystemService("phone")).getDeviceId();
        localObject = str3;
        if (localObject != null)
          continue;
        label55: SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("com.arellomobile.android.push.deviceid", 2);
        localObject = localSharedPreferences.getString("deviceid", null);
        if (localObject != null)
          continue;
        String str2 = UUID.randomUUID().toString();
        SharedPreferences.Editor localEditor = localSharedPreferences.edit();
        localEditor.putString("deviceid", str2);
        localEditor.commit();
        return str2;
      }
      catch (RuntimeException localRuntimeException)
      {
        break label55;
      }
    }
  }

  public static boolean isAppOnForeground(Context paramContext)
  {
    List localList = ((ActivityManager)paramContext.getSystemService("activity")).getRunningAppProcesses();
    if (localList == null);
    String str;
    ActivityManager.RunningAppProcessInfo localRunningAppProcessInfo;
    do
    {
      Iterator localIterator;
      while (!localIterator.hasNext())
      {
        return false;
        str = paramContext.getPackageName();
        localIterator = localList.iterator();
      }
      localRunningAppProcessInfo = (ActivityManager.RunningAppProcessInfo)localIterator.next();
    }
    while ((localRunningAppProcessInfo.importance != 100) || (!localRunningAppProcessInfo.processName.equals(str)));
    return true;
  }

  public static boolean isTablet(Context paramContext)
  {
    return (0x4 & paramContext.getResources().getConfiguration().screenLayout) == 4;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.arellomobile.android.push.utils.GeneralUtils
 * JD-Core Version:    0.6.2
 */